import time
from public.action import *
from public.business import *
from public.testData import *
from public.tools import *

testCase = "DBshop022_商品管理删除商品品牌"


# 1.点击“删除”按钮，确定删除，删除成功。


#打开dbshop的后台
firefox=openBrowser(urlAdmin)
#调用自定义函数进行后台的登录
DBshopLoginAdmin(firefox)
# 模拟鼠标操作，不能动鼠标
DBshopEnterMenu2(firefox,'商品管理','商品品牌')

# 点击删除
s22=firefox.find_elements_by_xpath('//table/tbody/tr/td[1]')
a22=[]
for i in s22:
    if "苹果" in i.text:
        a22.append(i.text)
        print(a22)
b=reGetString(a22[0],leftBinary=r"\(ID:",rightBinary=r"\)")
print(b)
firefox.find_element_by_xpath('//a[@onclick="return brand_del_js(%s);"]'%b).click()
firefox.switch_to.alert.accept()
time.sleep(2)




try:
    firefox.find_element_by_xpath('//a[@onclick="return brand_del_js(%s);"]'%b)
    writeLog("%s 测试不通过" % testCase)
    getPhoto(firefox)
except:
    writeLog("%s 测试成功" % testCase)

firefox.quit()
